*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* CULTURAL DISTANCE AND CONFLICT-RELATED SEXUAL VIOLENCE
* Eleonora Guarnieri - Ana Tur-Prats
* Quarterly Journal of Economics
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

*This do file replicates all tables in the main body of the paper and Figure 2.
*To replicate figures 1 and 3, please refer to the file "QGIS_Figures.qgz"

*++++++++++++++++++++++++++++++++++SET PATHS+++++++++++++++++++++++++++++++++++*

clear all
set more off
set maxvar 32767 

which reghdfe
*! version 5.7.3 13nov2019

*XXX NEW USER: edit this path. 
gl Path ""

*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

**# Figure 2

cd "$Path"
use Guarnieri_Tur-Prats_QJE_Main_Analysis, clear

label var side_P_matrilineal "Matrilineality"
label var side_P_nuclear "Nuclear family"
label var side_P_polygyny "Polygyny"
label var side_P_brideprice "Bride price"
label var side_P_shifting_agri "Shifting agriculture"
label var side_P_plough "Plough use"
label var side_P_pastoralism "Dependence on pastoralism"
label var side_P_nonherding_husbandry "Dep. on (non-herding) husbandry"
label var side_P_dep_gathering "Dependence on gathering"
label var side_P_dep_fishing "Dependence on fishing"


local family_traits matrilineal nuclear polygyny brideprice 
eststo clear
foreach x of local family_traits {
reghdfe CRSV side_P_`x', abs(conflict_new_id i.year i.conflict_new_id#c.year) vce(cluster side_P_FE)
eststo `x'
}
coefplot  matrilineal nuclear polygyny brideprice, drop(_cons ) xline(0) legend(off) title("Family Arrangements")

**
local subsistence_traits shifting_agri plough pastoralism nonherding_husbandry dep_gathering dep_fishing
eststo clear
foreach x of local subsistence_traits {
reghdfe CRSV side_P_`x', abs(conflict_new_id i.year i.conflict_new_id#c.year) vce(cluster side_P_FE)
eststo `x'
}
coefplot  shifting_agri plough pastoralism nonherding_husbandry dep_gathering dep_fishing, drop(_cons ) xline(0) legend(off)  title("Subsistence Activity")


**# Table 1

cd "$Path"
use Guarnieri_Tur-Prats_QJE_Index, clear

gl PCA "matrilineal polygyny shifting_agriculture non_herding_husbandry gathering fishing plough pastoralism nuclear brideprice" 

*Obtain loadings:

pca $PCA, comp(1)


*Note: the first component yields a "gender equality" index; since we compute a "male dominance" index, we invert the sign of the loadings:

matrix loadings = e(L)*(-1)


esttab matrix(loadings) using "Table1.tex", replace title(MDI: PCA loadings) rename(matrilineal "Matrilineal" polygyny "Polygyny" shifting_agri "Dependence on shifting agric." non_herding_husbandry "Dependence on non-herding husb." gathering "Dependence on gathering" fishing "Dependence on fishing" plough "Use of the plough" pastoralism "Dependence on pastoralism" nuclear "Nuclear family" brideprice "Brideprice")


**# Table 2 

cd "$Path"
use Guarnieri_Tur-Prats_QJE_DHS, clear

est sto clear

*Working 
reghdfe Working MDI,  abs(country_year) vce(cluster ethn#round)  
est sto u_1
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*Son preference 
reghdfe Son_Preference MDI, abs(country_year) vce(cluster ethn#round)
est sto u_2
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*if she goes out without telling him 
reghdfe Just_wf_goesout MDI, abs(country_year) vce(cluster ethn#round)
est sto u_3
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*if she neglets the children 
reghdfe Just_wf_neglects MDI, abs(country_year) vce(cluster ethn#round)
est sto u_4
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*if she argues with him  
reghdfe Just_wf_argues MDI, abs(country_year) vce(cluster ethn#round)
est sto u_5
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*if she refuses to have sex with him 
reghdfe Just_wf_refusessex MDI, abs(country_year)  vce(cluster ethn#round)
est sto u_6
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*if she burns the food  
reghdfe Just_wf_burnsfood MDI, abs(country_year)  vce(cluster ethn#round)
est sto u_7
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*Physical
reghdfe Severe_physical_IPV MDI, abs(country_year)  vce(cluster ethn#round)
est sto u_8
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

*Sexual IPV 
reghdfe Sexual_IPV MDI , abs(country_year) vce(cluster ethn#round)
est sto u_9
estadd ysumm
estadd scalar size=e(N)
estadd local cy_FE \checkmark

esttab u_* using "Table2.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(MDI) replace label title(MDI Validation: Demographic and Health Surveys) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)" "cy_FE Country-year FE") sfmt(3 0 0 3) lines noobs nonotes collabels(none) 


**# Table 3A

cd "$Path"
use Guarnieri_Tur-Prats_QJE_Main_Analysis, clear

est sto clear

reghdfe CRSV side_P_MDI, abs(conflict_new_id) vce(cluster side_P_FE)
est sto b_1
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark

reghdfe CRSV side_P_MDI, abs(conflict_new_id i.year) vce(cluster side_P_FE)
est sto b_2
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark

reghdfe CRSV side_P_MDI, abs(conflict_new_id i.year i.conflict_new_id#c.year) vce(cluster side_P_FE)
est sto b_3
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local con_spec_time \checkmark

reghdfe CRSV side_P_MDI, abs(conflict_new_id#year) vce(cluster side_P_FE)
est sto b_4
estadd ysumm
estadd scalar size=e(N)
estadd local confyear_FE \checkmark

reghdfe CRSV side_P_MDI, abs(conflict_new_id i.year i.conflict_new_id#c.year Country) vce(cluster side_P_FE)
est sto b_5
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local con_spec_time \checkmark
estadd local country_FE \checkmark


reghdfe CRSV side_P_MDI, abs(Country#year) vce(cluster side_P_FE)
est sto b_6
estadd ysumm
estadd scalar size=e(N)
estadd local countryyear_FE \checkmark


esttab b_* using "Table3A.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(side_P_*) replace label title(Male Dominance and CRSV: Main Results) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)" "conf_FE Conflict FE" "year_FE Year FE" "con_spec_time Conflict-specific time trend" "confyear_FE Conflict-year FE" "country_FE Country FE" "countryyear_FE Country-year FE") sfmt(3 0 0 3) lines noobs nonotes collabels(none) 
 

**# Table 3B

est sto clear

cd "$Path"
use Guarnieri_Tur-Prats_QJE_Main_Analysis, clear

reghdfe CRSV side_P_MDI, abs(side_V_FE) vce(cluster side_P_FE)
est sto e_1
estadd ysumm
estadd scalar size=e(N)
estadd local vic_FE \checkmark


reghdfe CRSV side_P_MDI, abs(side_V_FE i.year) vce(cluster side_P_FE)
est sto e_2
estadd ysumm
estadd scalar size=e(N)
estadd local vic_FE \checkmark
estadd local year_FE \checkmark

reghdfe CRSV side_P_MDI, abs(side_V_FE i.year conflict_new_id i.conflict_new_id#c.year) vce(cluster side_P_FE)   
est sto e_3
estadd ysumm
estadd scalar size=e(N)
estadd local vic_FE \checkmark
estadd local year_FE \checkmark
estadd local conf_FE \checkmark
estadd local con_spec_time \checkmark

reghdfe CRSV side_P_MDI, abs(side_V_FE Country) vce(cluster side_P_FE)
est sto e_4
estadd ysumm
estadd scalar size=e(N)
estadd local vic_FE \checkmark
estadd local country_FE \checkmark

reghdfe CRSV side_P_MDI, abs(side_V_FE Country year) vce(cluster side_P_FE)
est sto e_5
estadd ysumm
estadd scalar size=e(N)
estadd local vic_FE \checkmark
estadd local year_FE \checkmark
estadd local country_FE \checkmark

reghdfe CRSV side_P_MDI, abs(side_V_FE Country#year) vce(cluster side_P_FE)
est sto e_6
estadd ysumm
estadd scalar size=e(N)
estadd local vic_FE \checkmark
estadd local countryY_FE \checkmark

reghdfe CRSV side_P_MDI, abs(dyad) vce(cluster side_P_FE)
est sto e_7
estadd ysumm
estadd scalar size=e(N)
estadd local dyad_FE \checkmark



esttab e_* using "Table3B.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(side_P_MDI) replace label title(Male Dominance and CRSV: Victim Fixed Effects) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)" "vic_FE Victim FE" "year_FE Year FE" "conf_FE Conflict FE" "con_spec_time Conflict-specific time trend" "country_FE Country FE" "countryY_FE Country-year FE" "dyad_FE Dyad FE") sfmt(3 0 0 3) lines noobs nonotes collabels(none)  


**# Table 4

cd "$Path"
use Guarnieri_Tur-Prats_QJE_Main_Analysis, clear

est sto clear

reghdfe CRSV absolute_distance, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto f_1
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local con_spec_time \checkmark
estadd local perp_FE \checkmark

reghdfe CRSV side_P_MDI perpetrator_more, abs(conflict_new_id year conflict_new_id#c.year) vce(cluster dyad)
est sto f_2
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local con_spec_time \checkmark

reghdfe CRSV side_P_MDI perpetrator_less, abs(conflict_new_id year conflict_new_id#c.year) vce(cluster dyad)
est sto f_3
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local con_spec_time \checkmark

reghdfe CRSV side_P_MDI perpetrator_more perpetrator_less, abs(conflict_new_id year conflict_new_id#c.year) vce(cluster dyad)
est sto f_4
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local con_spec_time \checkmark

reghdfe CRSV perpetrator_more perpetrator_less, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto f_5
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local con_spec_time \checkmark
estadd local perp_FE \checkmark


esttab f_* using "Table4.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(absolute_distance side_P_MDI perpetrator_more perpetrator_less) replace label title(Cultural Distance in Gender Norms and CRSV) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)" "conf_FE Conflict FE" "year_FE Year FE" "con_spec_time Conflict-specific time trend" "perp_FE Perpetrator FE") sfmt(3 0 0 3) lines noobs nonotes collabels(none)  


**# Table 5

cd "$Path"
use Guarnieri_Tur-Prats_QJE_Main_Analysis, clear

est sto clear

reghdfe deaths_Inflicted side_P_MDI, abs(conflict_new_id year conflict_new_id#c.year) vce(cluster side_P_FE)
est sto i_1
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark 
estadd local con_spec_time \checkmark


reghdfe deaths_Inflicted perpetrator_more perpetrator_less, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto i_2
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark 
estadd local con_spec_time \checkmark


esttab i_* using "Table5.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(side_P_MDI perpetrator_more perpetrator_less) replace label title(Gender Norms and General Violence) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)" "conf_FE Conflict FE" "year_FE Year FE" "con_spec_time Conflict-specific time trend" "perp_FE Perpetrator FE") sfmt(3 0 0 3) lines noobs nonotes collabels(none)


**# Table 6

cd "$Path"
use Guarnieri_Tur-Prats_QJE_Main_Analysis, clear

est sto clear

reg Linguistic_distance absolute_distance
predict L_residuals, residuals

label var L_residuals "Linguistic distance (residuals)"


reghdfe CRSV absolute_distance Linguistic_distance, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto l1
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark 
estadd local con_spec_time \checkmark


reghdfe CRSV absolute_distance L_residuals, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto l2
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark 
estadd local con_spec_time \checkmark


reghdfe CRSV perpetrator_more perpetrator_less Linguistic_distance, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto l3
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark 
estadd local con_spec_time \checkmark


reghdfe CRSV perpetrator_more perpetrator_less L_residuals, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto l4
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark 
estadd local con_spec_time \checkmark


reghdfe CRSV Linguistic_distance, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto l5
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark s
estadd local con_spec_time \checkmark


reghdfe CRSV L_residuals, abs(conflict_new_id year conflict_new_id#c.year side_P_FE) vce(cluster dyad)
est sto l6
estadd ysumm
estadd scalar size=e(N)
estadd local conf_FE \checkmark
estadd local year_FE \checkmark
estadd local perp_FE \checkmark 
estadd local con_spec_time \checkmark


esttab l* using "Table6.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(absolute_distance Linguistic_distance L_residuals perpetrator_more perpetrator_less) replace label title(Linguistic Distance and CRSV) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)" "conf_FE Conflict FE" "year_FE Year FE" "con_spec_time Conflict-specific time trend" "perp_FE Perpetrator FE") sfmt(3 0 0 3) lines noobs nonotes collabels(none)



**# Table 7A

est sto clear

cd "$Path"
use Guarnieri_Tur-Prats_QJE_SFE, clear 

reghdfe CRSV side_P_MDI, abs(conflict_new_id year i.conflict_new_id#c.year) vce(cluster side_P_FE)
est sto q_1
estadd ysumm
estadd scalar size=e(N)

reghdfe CRSV side_P_MDI_SFE_off, abs(conflict_new_id year  i.conflict_new_id#c.year) vce(cluster side_P_FE_SFE)
est sto q_2
estadd ysumm
estadd scalar size=e(N)

reghdfe CRSV side_P_MDI_SFE_rank, abs(conflict_new_id year  i.conflict_new_id#c.year) vce(cluster side_P_FE_SFE)
est sto q_3
estadd ysumm
estadd scalar size=e(N)


esttab q_* using "Table7A.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(side_P*) replace label title(Test using the SFE Dataset: Officers vs Rank and File) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)") sfmt(3 0 0 3) lines noobs nonotes collabels(none)


**Table 7B

reghdfe CRSV perpetrator_more perpetrator_less, abs(side_P_FE conflict_new_id year i.conflict_new_id#c.year) vce(cluster dyad)
est sto r_1
estadd ysumm
estadd scalar size=e(N)

reghdfe CRSV perpetrator_more_SFE_off perpetrator_less_SFE_off, abs(side_P_FE_SFE conflict_new_id year i.conflict_new_id#c.year) vce(cluster dyad_SFE)
est sto r_2
estadd ysumm
estadd scalar size=e(N)

reghdfe CRSV perpetrator_more_SFE_rank perpetrator_less_SFE_rank, abs(side_P_FE_SFE conflict_new_id year i.conflict_new_id#c.year) vce(cluster dyad_SFE)
est sto r_3
estadd ysumm
estadd scalar size=e(N)


esttab r_* using "Table7B_fin.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(perpetrator_more* perpetrator_less*) replace label title(Test using the SFE Dataset: Officers vs Rank and File) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)") sfmt(3 0 0 3) lines noobs nonotes collabels(none)


**# Table 8A

cd "$Path"
use Guarnieri_Tur-Prats_QJE_RSVAC, clear

reghdfe  CRSV side_P_MDI, abs(conflict_new_id year i.conflict_new_id#c.year ) vce(cluster side_P_FE)  
est sto s_1
estadd ysumm
estadd scalar size=e(N)

reghdfe  rape side_P_MDI, abs(conflict_new_id year i.conflict_new_id#c.year) vce(cluster side_P_FE)  
est sto s_2
estadd ysumm
estadd scalar size=e(N)

reghdfe  nonrape side_P_MDI, abs(conflict_new_id year i.conflict_new_id#c.year) vce(cluster side_P_FE)  
est sto s_3
estadd ysumm
estadd scalar size=e(N)


esttab s_* using "Table8A.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(side_P*) replace label title(Gender Norms and Different Types of CRSV) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)") sfmt(3 0 0 3) lines noobs nonotes collabels(none)


*beta coefficients
reg  CRSV side_P_MDI i.conflict_new_id i.year i.conflict_new_id#c.year, beta 
reg  rape side_P_MDI i.conflict_new_id i.year i.conflict_new_id#c.year, beta 
reg  nonrape side_P_MDI i.conflict_new_id i.year i.conflict_new_id#c.year, beta 


*Table 8B

reghdfe  CRSV perpetrator_more perpetrator_less , abs(conflict_new_id year i.conflict_new_id#c.year side_P_FE) vce(cluster dyad)  
est sto t_1
estadd ysumm
estadd scalar size=e(N)

reghdfe  rape perpetrator_more perpetrator_less , abs(conflict_new_id year i.conflict_new_id#c.year side_P_FE) vce(cluster dyad)  
est sto t_2
estadd ysumm
estadd scalar size=e(N)

reghdfe  nonrape perpetrator_more perpetrator_less , abs(conflict_new_id year i.conflict_new_id#c.year side_P_FE) vce(cluster dyad)  
est sto t_3
estadd ysumm
estadd scalar size=e(N)


esttab t_* using "Table8B.tex", b(2) se(3) star(* 0.10 ** 0.05 *** 0.01) keep(perpetrator_more* perpetrator_less*) replace label title(Gender Norms and Different Types of CRSV) scalars("ymean Mean Dep. Var." "size Observations" "N_clust Clusters" "r2_a Adjusted \(R^{2}\)") sfmt(3 0 0 3) lines noobs nonotes collabels(none)

*beta coefficients

reghdfe  CRSV perpetrator_more perpetrator_less , abs(conflict_new_id year i.conflict_new_id#c.year side_P_FE) vce(cluster dyad)  
g sample=1 if e(sample)
reg  CRSV perpetrator_more perpetrator_less i.conflict_new_id i.year i.conflict_new_id#c.year i.side_P_FE if sample==1, beta 
drop sample

reghdfe  rape perpetrator_more perpetrator_less , abs(conflict_new_id year i.conflict_new_id#c.year side_P_FE) vce(cluster dyad)  
g sample=1 if e(sample)
reg  rape perpetrator_more perpetrator_less i.conflict_new_id i.year i.conflict_new_id#c.year i.side_P_FE if sample==1, beta 
drop sample

reghdfe  nonrape perpetrator_more perpetrator_less , abs(conflict_new_id year i.conflict_new_id#c.year side_P_FE) vce(cluster dyad)  
g sample=1 if e(sample)
reg  nonrape perpetrator_more perpetrator_less i.conflict_new_id i.year i.conflict_new_id#c.year i.side_P_FE if sample==1, beta
drop sample

